package com.hysf.ioc.pro2;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.concurrent.ThreadPoolExecutor;

public class App1 {
	public static void main(String[] args) {
		ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
		Product product = context.getBean(Product.class);
		System.out.println(product);
		
		ThreadPoolExecutor threadPoolExecutor = context.getBean(ThreadPoolExecutor.class);
		threadPoolExecutor.execute(new Runnable() {
			@Override
			public void run() {
				while (true) {
					try {
						Thread.sleep(1000);
					} catch (InterruptedException e) {
						throw new RuntimeException(e);
					}
					System.out.println("hello");
				}
			}
		});
		System.out.println(product);
	}
}
